home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 4.7 KB | 176 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPrvRAc.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPRVRAC_H
- #define FWPRVRAC_H
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- #ifndef FWFILESP_H
- #include "FWFileSp.h"
- #endif
-
- #ifndef FWRESFI_K
- #include "FWResFil.k"
- #endif
-
- #ifndef FWRESFI_H
- #include "FWResFil.h"
- #endif
-
- #ifndef FWCOUPTR_H
- #include "FWCouPtr.h"
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(__WINDOWS_H)
- #include <windows.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__TYPES__)
- #include <Types.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // CLASS FW_CPrivResourceRep
- //
- // This internal class is the reference counted representation class used by the
- // FW_CResource class defined above.
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPrivResourceRep : public FW_CCountedPtrRep
- {
- public:
- virtual ~ FW_CPrivResourceRep();
- // Releases the resource handle
-
- FW_CPrivResourceRep(const FW_CResourceFile &file,
- FW_ResourceId resourceId,
- FW_ResourceType resourceType);
- // Acquires the resource handle
-
- unsigned long GetSize() const;
- // Return the size of this resource in bytes.
-
- void* GetData();
- // Lock the resource and return a pointer to the data.
- // Client assumes responsiblity to call ReleaseData.
-
- void ReleaseData();
- // Unlock the resource.
-
- FW_ResourceHandle GetResourceHandle() const;
- // Return the platform (native) handle.
- // This method should be used with caution, since it reveals platform specifics,
- // and allows violation of internal lock counts, etc.
-
- private:
-
- FW_CResourceFile fResourceFile;
- // The resources file this resource originated from.
-
- FW_ResourceId fResourceID;
- // The resource ID of the resource.
-
- FW_ResourceType fResourceType;
- // The type of the resource.
-
- FW_ResourceHandle fResourceHandle;
- // The native resource handle.
-
- unsigned long fResourceSize;
- // The size of the resource, in bytes.
-
- unsigned long GetResourceSize(FW_ResourceHandle handle);
- // Return the size of the resource in bytes.
-
- #ifdef FW_BUILD_MAC
- unsigned short fLockCount;
- // Incremented for every GetData, decremented for every ReleaseData
-
- FW_PlatformHandle fResourceData;
- // Resource data is stored here.
- #endif
-
- #ifdef FW_BUILD_WIN
- HGLOBAL fLoadedHandle;
- #endif
-
- private:
-
- FW_CPrivResourceRep(const FW_CPrivResourceRep&);
- // Don't allow copy construction
-
- FW_CPrivResourceRep& operator=(const FW_CPrivResourceRep&);
- // Don't allow copy by value
-
- };
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivResourceRep::GetSize
- //----------------------------------------------------------------------------------------
-
- inline unsigned long FW_CPrivResourceRep::GetSize() const
- {
- return fResourceSize;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivResourceRep::GetResourceHandle
- //----------------------------------------------------------------------------------------
-
- inline FW_ResourceHandle FW_CPrivResourceRep::GetResourceHandle() const
- {
- return fResourceHandle;
- }
-
- //========================================================================================
- // CLASS FW_PPrivResourceAccess
- //========================================================================================
-
- class FW_CLASS_ATTR FW_PPrivResourceAccess : public FW_CCountedPtr
- {
- public:
- FW_PPrivResourceAccess(FW_CPrivResourceRep* privResourceAccessRep);
- virtual ~ FW_PPrivResourceAccess();
-
- // ----- Overload of accessors methods -----
- FW_CPrivResourceRep* operator->() const;
- FW_CPrivResourceRep& operator*() const;
- };
-
- //----------------------------------------------------------------------------------------
- // FW_PPrivResourceAccess::operator->
- //----------------------------------------------------------------------------------------
-
- inline FW_CPrivResourceRep* FW_PPrivResourceAccess::operator->() const
- {
- return (FW_CPrivResourceRep*)fRep;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PPrivResourceAccess::operator*
- //----------------------------------------------------------------------------------------
-
- inline FW_CPrivResourceRep& FW_PPrivResourceAccess::operator*() const
- {
- return *((FW_CPrivResourceRep*)fRep);
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-